/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.model.events;

/**
 * <p>This is a subclass of XREEvent that represents the "onTextMetadata" event. It defines some properties specific to
 * this event. Note that values of all custom properties are actually stored in the XREEvent#params map.</p>
 *
 * <p><strong>Thread safety:</strong> This class is mutable and not thread safe.</p>
 *
 * @author saarixx, jmn
 * @version 1.0
 */
@SuppressWarnings("boxing")
public class XRETextMetadataEvent extends XREResourceEvent {

    /**
     * <p>Represents the name of the "on text metadata" event.</p>
     *
     * <p>This is a string constant used by the user when setting the name of the event.</p>
     */
    public static final String ON_TEXT_METADATA_EVENT_NAME = "onTextMetadata";

    /**
     * <p>Represents the name used to retrieve the width parameter.</p>
     */
    private static final String WIDTH = "width";

    /**
     * <p>Represents the name used to retrieve the height parameter.</p>
     */
    private static final String HEIGHT = "height";

    /**
     * <p>Represents the name used to retrieve the ascent parameter.</p>
     */
    private static final String ASCENT = "ascent";

    /**
     * <p>Represents the name used to retrieve the descent parameter.</p>
     */
    private static final String DESCENT = "descent";

    /**
     * <p>Represents the name used to retrieve the leading parameter.</p>
     */
    private static final String LEADING = "leading";

    /**
     * <p>Creates new instance of {@link XRETextMetadataEvent} class.</p>
     */
    public XRETextMetadataEvent() {
        // empty constructor
    }

    /**
     * <p>Retrieves the measured width of the text, as it will appear on screen, in pixels.</p>
     *
     * @return the measured width of the text, as it will appear on screen, in pixels
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public double getWidth() {
        return getTypedParam(WIDTH, Double.class);
    }

    /**
     * <p>Sets the measured width of the text, as it will appear on screen, in pixels.</p>
     *
     * @param width the measured width of the text, as it will appear on screen, in pixels
     *
     * @throws IllegalStateException if params is null
     */
    public void setWidth(double width) {
        setParam(WIDTH, width);
    }

    /**
     * <p>Retrieves the measured height of the text, as it will appear on screen, in pixels.</p>
     *
     * @return the measured height of the text, as it will appear on screen, in pixels
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public double getHeight() {
        return getTypedParam(HEIGHT, Double.class);
    }

    /**
     * <p>Sets the measured height of the text, as it will appear on screen, in pixels.</p>
     *
     * @param height the measured height of the text, as it will appear on screen, in pixels
     *
     * @throws IllegalStateException if params is null
     */
    public void setHeight(double height) {
        setParam(HEIGHT, height);
    }

    /**
     * <p>Retrieves the ascent of the text, as it will be displayed, in pixels. The ascent refers to the vertical
     * distance from the tallest glyph to the baseline of the text.</p>
     *
     * @return the ascent of the text, as it will be displayed, in pixels
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public double getAscent() {
        return getTypedParam(ASCENT, Double.class);
    }

    /**
     * <p>Sets the ascent of the text, as it will be displayed, in pixels. The ascent refers to the vertical distance
     * from the tallest glyph to the baseline of the text.</p>
     *
     * @param ascent the ascent of the text, as it will be displayed, in pixels
     *
     * @throws IllegalStateException if params is null
     */
    public void setAscent(double ascent) {
        setParam(ASCENT, ascent);
    }

    /**
     * <p>Retrieves the descent of the text, as it will be displayed, in pixels. The descent refers to the vertical
     * distance from the baseline of the text to the lowest descender.</p>
     *
     * @return the descent of the text, as it will be displayed, in pixels
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public double getDescent() {
        return getTypedParam(DESCENT, Double.class);
    }

    /**
     * <p>Sets the descent of the text, as it will be displayed, in pixels. The descent refers to the vertical distance
     * from the baseline of the text to the lowest descender.</p>
     *
     * @param descent the descent of the text, as it will be displayed, in pixels
     *
     * @throws IllegalStateException if params is null
     */
    public void setDescent(double descent) {
        setParam(DESCENT, descent);
    }

    /**
     * <p>Retrieves the vertical distance between lines of text, in pixels.</p>
     *
     * @return the vertical distance between lines of text, in pixels
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public double getLeading() {
        return getTypedParam(LEADING, Double.class);
    }

    /**
     * <p>Sets the vertical distance between lines of text, in pixels.</p>
     *
     * @param leading the vertical distance between lines of text, in pixels
     *
     * @throws IllegalStateException if params is null
     */
    public void setLeading(double leading) {
        setParam(LEADING, leading);
    }
}

